#!/bin/bash

echo "Preparing to discover all names linked to target player!"
echo "Warning: this finds all names which logged in using the same IP(s) as the target name."
echo "This does not prove that the names are the same person, or even remotely related!"
echo "Use good judgement when deciding what to do with this information."

target=${1}
debug="/home/minetest/logs/debug.txt"
list="$(cat $debug | grep "joins game" | grep $target | grep -P "\[\d+\.\d+\.\d+\.\d+\]" -oh | uniq)"
total="$(for item in $list; do grep -F "$item" $debug | grep -P "\w+\s+\[\d+\.\d+\.\d+\.\d+\]\s+joins game\." -o; done)"
lines="$(echo "$total" | grep -P "^\w+" -o)"
sorted="$(echo "$lines" | sort)"

echo "================================================================================"
echo "$sorted" | uniq
echo "================================================================================"
echo "Done!"

